package me.twoday.library.mine.common;

import java.util.Locale;

import me.twoday.library.mine.common.base.BaseApplication;
import android.util.Log;

/**
 * xml을 사용한 국제화를 위한 클래스  
 * 
 * @author 김학성
 * @since 2012. 4. 18.
 */
public class LanguageUtil 
{
	public static final String TAG = "LanguageUtil";
	public static final int KO = 1;
	public static final int EN = 2;
	public static final int JP = 3;
	public static final int CH = 4;
	private static Locale systemLocale = BaseApplication.getContext().getResources().getConfiguration().locale; 
	
	private static final String selectedLanguage = BaseApplication.getConfigPersistent("language");
	
	
	public static void printLanguage()
	{
		String strDisplayCountry = systemLocale.getDisplayCountry();
		String strCountry = systemLocale.getCountry();
		String strLanguage = systemLocale.getLanguage();
		String strDispalyLanguage = systemLocale.getDisplayLanguage();
		Log.e("strDisplayCountry", strDisplayCountry);
		Log.e("strCountry", strCountry);
		Log.e("strLanguage", strLanguage);
		Log.e("strDispalyLanguage", strDispalyLanguage);
		
	}
	
	
	/**
	 * 언어설정에 관해 가독성을 높이기위해 만든 함수
	 *
	 * @return 설정된 언어의 final값 
	 */
	public static final int selectLanguage()
	{
		int selectedLnagNum = 0;
		
		if(selectedLanguage.equals("ko"))
		{
			selectedLnagNum = KO;
		}
		else if(selectedLanguage.equals("en"))
		{
			selectedLnagNum = EN;
		}
		else if(selectedLanguage.equals("jp"))
		{
			selectedLnagNum = JP;
		}
		else if(selectedLanguage.equals("ch"))
		{
			selectedLnagNum = CH;
		}
		else
		{
			Log.e(TAG, "언어설정이 되지 않았습니다.");
		}
		return selectedLnagNum;
	}
}
